<?php

	$unit = 20;
	if($_POST)
	{	
		if($_POST['tp']=="doupdate")
		{
			$json = (array)json_decode(str_replace('\\','',$_POST['json']));
			$data = array(
				'qvod_path' => $json['new_qvod_path'],
				'from_path' => $json['from_path'],
				'qvod_type' => $json['qvod_type']
			);
			if($_->qvodSource->_update($data,array('id '=>$json['id'])))
			{
				echo 'OK';
			}else{
				echo 'null';
			}exit;
		}
		$_POST['page'] = $_POST['page']?$_POST['page']:1;		
		$_POST['id']?$condition['id']=$_POST['id']:'';
		$_POST['type']?$condition['qvod_type']=$_POST['type']:'';
		$_POST['name']?$condition['name LIKE']=$_POST['name']:'';
		$condition['LIMIT'] = ($_POST['page']-1)*$unit.','.$unit;
		$data = $_->qvodSource->_select('*',$condition);
		if($_POST['tp']=="update")
		{
			$domian = "http://www.313zy.com";
			$h = parse_url($data[0]['from_path']);
			$data[0]['from_path'] = $h['path'];
			$file = mb_convert_encoding(file_get_contents($domian.$data[0]['from_path']), "UTF-8", "GB2312");
			if($file)
			{
				preg_match_all("/<input type=\'checkbox\' name=\'copy_yah\' id=\'copy_yah\' value=\'([^\']+)\'  checked\/>/",$file, $match, PREG_PATTERN_ORDER);
				preg_match_all("/<font color=\"#000\"><!--影片类型开始代码-->(.+)<!--影片类型结束代码--><\/font>/",$file, $cate, PREG_PATTERN_ORDER);
			}
			$data[0]['new_qvod_path'] = trim($match[1][0]);
			$data[0]['qvod_type'] = trim($cate[1][0]);
		}
		echo json_encode($data);exit;
	}
	$data = $_->qvodSource->_select('*',array('LIMIT'=>'0,'.$unit));

	$smarty->_assign(array('data'));
	$smarty->_display();
?>